﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HotelG11.Models;

namespace HotelG11.Controllers
{
    public class RoomsController : Controller
    {
        public ActionResult Index()
        {
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            List<HangPhong> HP = new List<HangPhong>();
            var res = G11.sp_LayDSHangPhong();
            HP = res.ToList<HangPhong>();
            return View(HP);
        }

        public ActionResult Details(string id, string hang)
        {
            ViewBag.hang = hang;
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            List<G11_DSDichVu> DV = new List<G11_DSDichVu>();
            var res1 = G11.G11_DSDichVu.ToList();
            DV = res1.ToList<G11_DSDichVu>();
            ViewBag.DV = DV;
            List<LoaiPhong_HangPhong> LP = new List<LoaiPhong_HangPhong>();
            var res = G11.sp_LayDSLoaiPhongTheoHangPhong(id);
            LP = res.ToList<LoaiPhong_HangPhong>();
            return View(LP);
        }

        public ActionResult Booking()
        {
            return View();
        }
        [HttpGet]
        public ActionResult ListLoaiHangPhongHoTro(string from_date,string to_date)
        {
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            List<DSLoaiPhongHangPhongHoTro> DSLPHP = new List<DSLoaiPhongHangPhongHoTro>();
            var res = G11.sp_LayDSLoaiHangPhongHoTro(Convert.ToDateTime(from_date), Convert.ToDateTime(to_date));
            DSLPHP = res.ToList<DSLoaiPhongHangPhongHoTro>();
            return PartialView(DSLPHP);
        }
        [HttpGet]
        public ActionResult InsertReservation(string from_date, string to_date, int count, string name, string add, string phone, string code, string name_acc, string pass_acc)
        {
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            string maDP = G11.sp_DatPhong_KH(Convert.ToDateTime(from_date), Convert.ToDateTime(to_date), count, name, add, phone, code, name_acc, pass_acc).FirstOrDefault();
            return Content(maDP);
        }
        [HttpGet]
        public ActionResult InsertReservationDetail(string room, string type , int count, string from_date, string to_date, string maDP)
        {
            G11KhachSanEntities G11 = new G11KhachSanEntities();
            G11.sp_ThemPhongDat(room, type, count ,Convert.ToDateTime(from_date), Convert.ToDateTime(to_date), maDP);
            return Content(maDP);
        }

    }
}
